# nodemon --watch 02dic.py --exec 'python 02dic.py'

print('hello world')

print('same key',{'name':'bobo','age':18,'age':20})

d = {'name':'bobo','age':20,"scores": [100,120,99]}

print(d['name'],d['age'])
# print(d['no-exist']) #will throw KeyError: 'no-exist'

print(d.get('name'))
print(d.get('no-exist')) #will return None

print(d.keys())
print(d.values())
print(d.items())


# 练习
# 写⼀个程序，输出100以内的所有偶数，直到累加和⼤于1000停⽌程序。
val = 0
acc = 0
while(True):
    print(val)
    acc+= val
    if acc > 1000:
        break
    val+=2


# 已知a+b+c=1000且a^2+b^2=c^2(a,b,c都是⾃然数)，求出 符合条件的a,b,c的所有组合。
for a in range(1,1000):
    for b in range(1,1000):
        c = 1000 - a - b
        if a**2 + b**2 == c**2:
            print(a,b,c)
            
# 给定⼀个字符串string = "Hello, World!"，请统计字符串中
# 每个字符的出现次数，并将结果存储在⼀个字典中 
d = {}
for c in 'Hello, World!':
    if c in d:
        d[c] += 1
    else:
        d[c] = 1
print(d)


# 猜数字游戏设计：可以不间断的进⾏猜数字游戏环节，找到
# 猜对了，结束程序，猜不对，可以不断的进⾏游戏，并且需
# 要提示⽤户猜打了还是猜⼩了。
import random
guess_num = random.randint(1,10)
score = 100
while(True):
    guess = input('guess a number between 1 and 10:')
    if int(guess) == guess_num:
        print('you win!')
        break
    elif int(guess) > guess_num:
        print('too big')
    else:
        print('too small')
print(guess_num)